/**
 * 
 */
package com.dream.house.dao.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import cn.com.servyou.base.exception.DAOException;

import com.dream.house.dao.RentDAO;
import com.dream.house.dao.base.HouseBaseDAO;
import com.dream.house.entity.BuyDTO;
import com.dream.house.entity.RentDTO;

/**
 * @author ahk
 * @since 1.0
 */
public class RentDAOImpl extends HouseBaseDAO implements RentDAO {

	/* (non-Javadoc)
	 * @see com.dream.house.dao.RentHouseDAO#saveRent(com.dream.house.entity.RentDTO)
	 */
	@Override
	public boolean saveRent(RentDTO dto) throws DAOException {
		
		return createEntity("saveRent", dto);
	}

	/* (non-Javadoc)
	 * @see com.dream.house.dao.RentHouseDAO#updateRent(com.dream.house.entity.RentDTO)
	 */
	@Override
	public boolean updateRent(RentDTO dto) throws DAOException {
		
		return updateEntity("updateRent", dto);
	}

	/* (non-Javadoc)
	 * @see com.dream.house.dao.RentHouseDAO#removeRent(java.lang.String)
	 */
	@Override
	public boolean removeRent(String id) throws DAOException {
		
		return removeEntity("removeRent", id);
	}

	/* (non-Javadoc)
	 * @see com.dream.house.dao.RentHouseDAO#getRent(java.lang.String)
	 */
	@Override
	public RentDTO getRent(String id) throws DAOException {
		
		return (RentDTO)getEntity("getRent",id);
	}
	
	@SuppressWarnings("unchecked")
	public List<RentDTO> getRentsByRoom(String room_id) throws DAOException{
		return (List<RentDTO>)getEntitys("getRentsByRoom",room_id);
	}

	/* (non-Javadoc)
	 * @see com.dream.house.dao.RentHouseDAO#findRents(java.util.Map)
	 */
	@SuppressWarnings("unchecked")
	@Override
	public List<RentDTO> findRents(RentDTO dto) throws DAOException {
		
		return (List<RentDTO>)getEntitys("findRents", dto);
	}
	
	@Override
	public boolean updateRentStatus(String id, String status)
			throws DAOException {
		
		Map<String,Object> map=new HashMap<String,Object>();
		map.put("id", id);
		map.put("status", status);
		
		return updateEntity("updateRentStatus", status);
	}
	
	/* (non-Javadoc)
	 * @see cn.com.servyou.base.dao.BaseDAO#getEntityName()
	 */
	@Override
	public String getEntityName() {
		return RentDTO.class.getCanonicalName();
	}
}
